package com.hdu.hot100.arr;

public class lc238 {
    class Solution {
        public int[] productExceptSelf(int[] nums) {

            // 1,2,3,4
            int[] arr = new int[nums.length];
            int prev = 1;
            for (int i = 0; i < nums.length; i++)
            {
                arr[i] = prev;
                prev *= nums[i];
            }
            prev = 1;
            for (int i = nums.length - 1; i >= 0; i--)
            {
                arr[i] *= prev;
                prev *= nums[i];
            }
            return arr;
        }
    }
}
